let arr =[1,2,3,3,1]
// let newArr =[...new Set(arr)]
// console.log(newArr);

function unique(arr){
    arr.sort()
    for(let i=0;i<arr.length;i++){
        let j =i +1
        if(arr[i]===arr[j]){
            arr.splice(j,1)
            i--
        }
    }
    return arr
}
console.log(unique(arr));